﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class VirtualPath_VirtualPath : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HyperLink5.NavigateUrl = VirtualPathUtility.ToAbsolute("~/1.html");
        //VirtualPathMethods();
    }

    void VirtualPathMethods()
    {
        string p1 = VirtualPathUtility.ToAbsolute("~/a");
        string p2 = "1.html";
        string p3 = VirtualPathUtility.ToAbsolute("~/a/1.html");

        //string p1 = "~/a";
        //string p2 = "1.html";
        //string p3 = "~/a/1.html";

        // 如果路径最后没有"/"则添加。
        string path1 = VirtualPathUtility.AppendTrailingSlash(p1);
        // 将两个路径进行合并
        string path2 = VirtualPathUtility.Combine(p1,p2);
        // 返回虚拟路径的目录部分
        string path3 = VirtualPathUtility.GetDirectory(p3);
        // 计算两个路径的相对路径
        string path4 = VirtualPathUtility.MakeRelative(p1, p3);
        //转换为绝对路径
        string path5 = VirtualPathUtility.ToAbsolute("~/a");

    }
}